package com.vcourse.service.edu.controller.api;

import com.vcourse.commons.result.R;
import com.vcourse.service.edu.entity.Teacher;
import com.vcourse.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author Zengsh123
 * @date 2020-06-06 21:12
 */
@Api("前台讲师接口")
@Slf4j
@RestController
@RequestMapping("/api/edu/teacher")
public class ApiTeacherController {
    @Resource
    private TeacherService teacherService;

    @ApiOperation("查询所有讲师")
    @GetMapping("/listAll")
    public R listAll() {
        List<Teacher> list = teacherService.list();
        return R.ok().data(list);
    }

    @ApiOperation("查询讲师信息")
    @GetMapping("/info/{id}")
    public R info(@ApiParam(value = "讲师id", required = true)
                  @PathVariable String id) {
        Map<String, Object> info = teacherService.getTeacherInfo(id);
        return R.ok().data(info);
    }
}
